﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefQcSheet" :model="stateQcSheet.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_WoId_FormItem" prop="LinkedVM.WoId" :label="$t('message.autotrans._Model_QcSheet_WoId')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.WoId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_WoCode_FormItem" prop="LinkedVM.WoCode" :label="$t('message.autotrans._Model_QcSheet_WoCode')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.WoCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductId_FormItem" prop="LinkedVM.ProductId" :label="$t('message.autotrans._Model_QcSheet_ProductId')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.ProductId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductName_FormItem" prop="LinkedVM.ProductName" :label="$t('message.autotrans._Model_QcSheet_ProductName')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.ProductName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_QcMode_FormItem" prop="LinkedVM.QcMode" :label="$t('message.autotrans._Model_QcSheet_QcMode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_QcSheet_QcMode')}), trigger: 'blur' }]" >
          <el-select v-model="stateQcSheet.vmModel.LinkedVM.QcMode" clearable>
             <el-option key="IQC" value="IQC" :label="$t('message.autotrans._Enum_QcModeEnum_IQC')"></el-option>
             <el-option key="IPQC" value="IPQC" :label="$t('message.autotrans._Enum_QcModeEnum_IPQC')"></el-option>
             <el-option key="FQC" value="FQC" :label="$t('message.autotrans._Enum_QcModeEnum_FQC')"></el-option>
             <el-option key="OQC" value="OQC" :label="$t('message.autotrans._Enum_QcModeEnum_OQC')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Sn_FormItem" prop="LinkedVM.Sn" :label="$t('message.autotrans._Model_QcSheet_Sn')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.Sn" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_TemplateId_FormItem" prop="LinkedVM.TemplateId" :label="$t('message.autotrans._Model_QcSheet_Template')">
          <el-select v-model="stateQcSheet.vmModel.LinkedVM.TemplateId" clearable>
             <el-option v-for="item in stateQcSheet.AllTemplates" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_QcOperator_FormItem" prop="LinkedVM.QcOperator" :label="$t('message.autotrans._Model_QcSheet_QcOperator')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.QcOperator" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_QcResult_FormItem" prop="LinkedVM.QcResult" :label="$t('message.autotrans._Model_QcSheet_QcResult')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_QcSheet_QcResult')}), trigger: 'blur' }]" >
          <el-select v-model="stateQcSheet.vmModel.LinkedVM.QcResult" clearable>
             <el-option key="Ok" value="Ok" :label="$t('message.autotrans._Enum_QcStatusEnum_Ok')"></el-option>
             <el-option key="NG" value="NG" :label="$t('message.autotrans._Enum_QcStatusEnum_NG')"></el-option>
             <el-option key="Doing" value="Doing" :label="$t('message.autotrans._Enum_QcStatusEnum_Doing')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Remark_FormItem" prop="LinkedVM.Remark" :label="$t('message.autotrans._Model_QcSheet_Remark')">
          <el-input v-model="stateQcSheet.vmModel.LinkedVM.Remark" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitQcSheet"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseQcSheet"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageQcManagementQcSheetBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { qcsheetApi } from '/@/api/qcmanagement/qcsheet';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefQcSheet = ref();
const stateQcSheet = reactive({
    vmModel: {
	  LinkedVM:{
        WoId: '',
        WoCode: '',
        ProductName: '',
        QcMode: undefined,
        Sn: '',
        TemplateId: null,
        QcOperator: '',
        QcResult: undefined,
        Remark: '',
      },
      Ids:[],
      
	},
    
    AllTemplates: [] as any[],
});

// 取消
const onCloseQcSheet = () => {
    closeDialog();
};

// 提交
const onSubmitQcSheet = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefQcSheet.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            qcsheetApi().batchedit(stateQcSheet.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/QcManagement/QcSheet/GetQcTemplates',[],false).then(x=>{stateQcSheet.AllTemplates = x});
    if (ci.attrs["wtmdata"]) {
		stateQcSheet.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateQcSheet.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

